﻿using MapleLeaf.DataBase.Repository;
using MapleLeaf.Model.CookBook.Menu.Entity;
using SqlSugar;

namespace MapleLeaf.Service.CookBook.Menu {
    /// <summary>
    /// 菜单服务
    /// </summary>
    public class SystemMenuService(ISqlSugarClient db) : DataBaseRepository<MenuEntity>(db), Interface.IScopedService {

        /// <summary>
        /// 获取菜单权限列表
        /// </summary>
        /// <returns></returns>
        public List<string> GetMenuPermissionList(string roleCode) {
            var sql = @$"select m.perm  from public.sys_menu m
                        inner join public.sys_role_menu rm on m.id = rm.menu_id
                        inner join public.sys_role r on rm.role_id =r.id
                       where m.perm is not null and r.code  ='{roleCode}' ";
            var result = db.Ado.SqlQuery<string>(sql);
            return result;
        }

   
    }
}
